package com.yjt.fresh.fragment;

import android.os.Bundle;
import android.view.View;
import android.widget.ImageView;

import com.bumptech.glide.Glide;
import com.shuyu.gsyvideoplayer.GSYVideoManager;
import com.shuyu.gsyvideoplayer.player.IjkPlayerManager;
import com.shuyu.gsyvideoplayer.player.PlayerFactory;
import com.shuyu.gsyvideoplayer.video.StandardGSYVideoPlayer;
import com.yjt.fresh.R;
import com.yjt.fresh.base.BaseSimpleFragment;
import com.yjt.fresh.bean.BeanHistory;
import com.yjt.fresh.constant.MyConstants;



/**
 * 视频
 * Created by mcc on 2018-08-08.
 */

public class FrgVideo extends BaseSimpleFragment {


    private StandardGSYVideoPlayer mPlayer;

    @Override
    protected int getContentView() {
        return R.layout.app_frg_video;
    }

    @Override
    protected void initView(Bundle savedInstanceState, View view) {
        BeanHistory beanHistory = (BeanHistory) getArguments().getSerializable(MyConstants.VIDEO_OBJ);
        mPlayer = view.findViewById(R.id.playerAppFrgVideo);
        mPlayer.setUp(beanHistory.getVIDEO(),false,beanHistory.getTITLE());
        mPlayer.getBackButton().setVisibility(View.GONE);
        mPlayer.getFullscreenButton().setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                mPlayer.startWindowFullscreen(mContext,true,true);
            }
        });

        mPlayer.setAutoFullWithSize(true);
        ImageView imageView = new ImageView(mContext);
        imageView.setScaleType(ImageView.ScaleType.CENTER_CROP);
        Glide.with(mContext).load(beanHistory.getVIDEOIMG()).placeholder(R.mipmap.image_default).into(imageView);
        mPlayer.setThumbImageView(imageView);
        mPlayer.setThumbPlay(true);
        PlayerFactory.setPlayManager(new IjkPlayerManager());
    }


    @Override
    protected void initEvents() {

    }

    @Override
    public void onStop() {
        super.onStop();
    }
}
